/**
 * 键盘鼠标输入类
 * 监测键盘和鼠标的输入
 *
 *
 *
 */
var keyboardmouse = function () {
    var keyMaps = {
			'13': 'Click',	//回车键，和鼠标点击效果相同
			'17': 'Skip'	//Ctrl键，提供快速阅读功能（完全没有想好这个要怎么做……）
		},
		keyInfo = {
			'Click': false,
			'Skip' : false
		},
		key,
		leftMouseClicked = false,
		that = {
		// 等待鼠标点击或者键盘按键
        waitClick: function () {
            //leftMouseClicked = false;
			//keyInfo['Click'] = false;
            sys.changeStatus('waitclick');
            var timer1 = setInterval(function(){
                if (leftMouseClicked || keyInfo['Click']) {
                    //alert('mouseClicked:'+ mouseClicked + 'isRunning:' + isRunning);
                    leftMouseClicked = false;
					keyInfo['Click'] = false;
                    sys.changeStatus('getscript');
                    clearInterval(timer1);
                }
            },100);
        },
		// 处理鼠标点击
        click: function (event) {
			// 必须处于等待或者菜单状态才接受鼠标点击
			if (sys.getStatus() == 'waitclick' || sys.getStatus() == 'menu') {
				// 左键点击
				if (event.which == 1)
					if (sys.getStatus() == 'menu'){
						// 什么都不做
					}
					else{
						leftMouseClicked = true;
					}
				// 中键点击
				if (event.which == 2)
					alert('Middle Mouse!');
				// 右键点击
				if (event.which == 3)
					sm.showMenu();
			}
        },
		// 处理键盘按键
		press: function(event) {
			if (sys.getStatus() == 'waitclick'){
				key = '' + event.which;
				if (keyMaps[key] !== undefined) {
					keyInfo[keyMaps[key]] = event.type === 'keypress' ? true : false;
					return false;
				}
			}
		},
		disableClickLeft: function () {
			
		}
    };
    return that;
}